﻿@using System.IO
@using Microsoft.AspNetCore.Mvc.Razor
@using Microsoft.AspNetCore.Mvc.ViewFeatures
@using Ocelot.ConfigEditor
@using Ocelot.ConfigEditor.Editor.Models
@model FileReRouteViewModel

<div class="panel-group">
    <div class="panel panel-default">
        <div class="panel-heading">
            <h3 class="panel-title">
                Service Details
            </h3>
        </div>
        <div class="panel-body">
            <div class="form-group">
                <label asp-for="FileReRoute.ServiceName"></label>
                <input asp-for="FileReRoute.ServiceName" class="form-control"/>
                <span asp-validation-for="FileReRoute.ServiceName" class="text-danger"></span>
            </div>
            <div class="form-group">
                <label asp-for="FileReRoute.ReRouteIsCaseSensitive"></label>
                <input asp-for="FileReRoute.ReRouteIsCaseSensitive" class="form-control"/>
            </div>
            
            <div class="form-group">
                <label asp-for="FileReRoute.RequestIdKey"></label>
                <input asp-for="FileReRoute.RequestIdKey" class="form-control"/>
            </div>
        </div>
    </div>
</div>
<div class="panel-group">
    <div class="panel panel-default">
        <div class="panel-heading">
            <h3 class="panel-title">
                Downstream
            </h3>
        </div>
        <div class="panel-body">
            <div class="form-group">
                <label asp-for="FileReRoute.DownstreamScheme" class="required"></label>
                <select asp-for="FileReRoute.DownstreamScheme" asp-items="Model.SchemeListItems" class="form-control"></select>
                <span asp-validation-for="FileReRoute.DownstreamScheme" class="text-danger"></span>
            </div>
            <div class="form-group">
                <label class="required">Host and Port</label>
                <span asp-validation-for="FileReRoute.DownstreamHostAndPorts" class="text-danger"></span>
                <div class="form-group">
                    <a href="#" id="button-hostport-add" class="btn btn-primary"><span class="fas fa-plus"></span> Add</a>
                </div>
                <div id="host-port" class="form-group">
                    @for (var i = 0; i < Model.FileReRoute.DownstreamHostAndPorts.Count; i++)
                    {
                        <div class="form-group">
                            <input asp-for="FileReRoute.DownstreamHostAndPorts[i].Host" class="required"/>
                            <input asp-for="FileReRoute.DownstreamHostAndPorts[i].Port" class="required"/>
                            <a href="#" class="btn btn-xs btn-default textbox-remove">
                                <span class="fas fa-trash"></span>
                            </a>
                        </div>
                    }
                    <input type="hidden" id="host-port-index" value="@(Model.FileReRoute.DownstreamHostAndPorts.Count)"/>
                </div>
            </div> 
            <div class="form-group">
                <label asp-for="FileReRoute.DownstreamPathTemplate" class="required"></label>
                <input asp-for="FileReRoute.DownstreamPathTemplate" placeholder="/" class="form-control"/>
                <span asp-validation-for="FileReRoute.DownstreamPathTemplate" class="text-danger"></span>
            </div>
        </div>
    </div>
</div>
<div class="panel-group">
    <div class="panel panel-default">
        <div class="panel-heading">
            <h3 class="panel-title">
                Upstream
            </h3>
        </div>
        <div class="panel-body">
            <div class="form-group">
                <label asp-for="FileReRoute.UpstreamPathTemplate"></label>
                <input asp-for="FileReRoute.UpstreamPathTemplate" placeholder="/" class="form-control"/>
            </div>
            <div class="form-group">
                <label asp-for="FileReRoute.UpstreamHttpMethod"></label>
                <select asp-for="FileReRoute.UpstreamHttpMethod" asp-items="Model.HttpMethodListItems" multiple class="form-control"></select>
            </div>
        </div>
    </div>
</div>
<div class="panel-group">
    <div class="panel panel-default">
        <div class="panel-heading">
            <h3 class="panel-title">
                <a data-toggle="collapse" href="#panel-qos-options">QoS Options</a>
            </h3>
        </div>
        <div id="panel-qos-options" class="panel-collapse collapse">
            <div class="panel-body">
                <div class="form-group">
                    <label asp-for="FileReRoute.QoSOptions.ExceptionsAllowedBeforeBreaking"></label>
                    <input asp-for="FileReRoute.QoSOptions.ExceptionsAllowedBeforeBreaking" class="form-control"/>
                </div>
                <div class="form-group">
                    <label asp-for="FileReRoute.QoSOptions.DurationOfBreak"></label>
                    <input asp-for="FileReRoute.QoSOptions.DurationOfBreak" class="form-control"/>
                </div>
                <div class="form-group">
                    <label asp-for="FileReRoute.QoSOptions.TimeoutValue"></label>
                    <input asp-for="FileReRoute.QoSOptions.TimeoutValue" class="form-control"/>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="panel-group">
    <div class="panel panel-default">
        <div class="panel-heading">
            <h3 class="panel-title">
                <a data-toggle="collapse" href="#panel-authentication">Authentication Options</a>
            </h3>
        </div>
        <div id="panel-authentication" class="panel-collapse collapse">
            <div class="panel-body">
                <div class="form-group">
                    <label asp-for="FileReRoute.AuthenticationOptions.AuthenticationProviderKey"></label>
                    <input asp-for="FileReRoute.AuthenticationOptions.AuthenticationProviderKey" class="form-control" />
                </div>
                <label>Allowed Scopes</label>
                <div class="form-group">
                    <a href="#" id="button-allowedscope-add" class="btn btn-primary"><span class="fas fa-plus"></span> Add</a>
                </div>
                <div id="allowed-scope">
                    @for (var i = 0; i < Model.FileReRoute.AuthenticationOptions.AllowedScopes.Count; i++)
                    {
                        <div class="form-group">
                            <input asp-for="FileReRoute.AuthenticationOptions.AllowedScopes[i]"/>
                        </div>
                    }
                    <input type="hidden" id="allowed-scope-index" value="@(Model.FileReRoute.AuthenticationOptions.AllowedScopes.Count)"/>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="panel-group">
    <div class="panel panel-default">
        <div class="panel-heading">
            <h3 class="panel-title">
                <a data-toggle="collapse" href="#panel-headers">Add Headers to Request</a>
            </h3>
        </div>
        <div id="panel-headers" class="panel-collapse collapse">
            <div class="panel-body">
                <div class="form-group">
                    <a href="#" id="button-headers-add" class="btn btn-primary"><span class="fas fa-plus"></span> Add</a>
                </div>
                <div id="request-headers">
                    @foreach (var key in Model.FileReRoute.AddHeadersToRequest.Keys)
                    {
                        <div class="form-group">
                            <input type="text" value="@key" class="headers-key"/>
                            <input asp-for="FileReRoute.AddHeadersToRequest[key]"/>
                        </div>
                    }
                </div>
            </div>
        </div>
    </div>
</div>
<div class="panel-group">
    <div class="panel panel-default">
        <div class="panel-heading">
            <h3 class="panel-title">
                <a data-toggle="collapse" href="#panel-claims">Add Claims to Request</a>
            </h3>
        </div>
        <div id="panel-claims" class="panel-collapse collapse">
            <div class="panel-body">
                <div class="form-group">
                    <a href="#" id="button-claims-add" class="btn btn-primary"><span class="fas fa-plus"></span> Add</a>
                </div>
                <div id="request-claims">
                    @foreach (var key in Model.FileReRoute.AddClaimsToRequest.Keys)
                    {
                        <div class="form-group">
                            <input type="text" value="@key" class="claims-key"/>
                            <input asp-for="FileReRoute.AddClaimsToRequest[key]"/>
                            <a href="#" class="btn btn-xs btn-default textbox-remove">
                                <span class="fas fa-remove"></span>
                            </a>
                        </div>
                    }
                </div>
            </div>
        </div>
    </div>
</div>
<div class="panel-group">
    <div class="panel panel-default">
        <div class="panel-heading">
            <h3 class="panel-title">
                <a data-toggle="collapse" href="#panel-queries">Add Queries to Request</a>
            </h3>
        </div>
        <div id="panel-queries" class="panel-collapse collapse">
            <div class="panel-body">
                <div class="form-group">
                    <a href="#" id="button-queries-add" class="btn btn-primary"><span class="fas fa-plus"></span> Add</a>
                </div>
                <div id="request-queries">
                    @foreach (var key in Model.FileReRoute.AddQueriesToRequest.Keys)
                    {
                        <div class="form-group">
                            <input type="text" value="@key" class="queries-key"/>
                            <input asp-for="FileReRoute.AddQueriesToRequest[key]"/>
                        </div>
                    }
                </div>
            </div>
        </div>
    </div>
</div>
<div class="panel-group">
    <div class="panel panel-default">
        <div class="panel-heading">
            <h3 class="panel-title">
                <a data-toggle="collapse" href="#panel-loadBalance">Load Balance Options</a>
            </h3>
        </div>
        <div id="panel-loadBalance" class="panel-collapse collapse">
            <div class="panel-body">
                <div class="form-group">
                    <label asp-for="FileReRoute.LoadBalancerOptions.Key"></label>
                    <input asp-for="FileReRoute.LoadBalancerOptions.Key" class="form-control"/>
                </div>
                <div class="form-group">
                    <label asp-for="FileReRoute.LoadBalancerOptions.Type"></label>
                    <input asp-for="FileReRoute.LoadBalancerOptions.Type" class="form-control"/>
                </div>
                <div class="form-group">
                    <label asp-for="FileReRoute.LoadBalancerOptions.Expiry"></label>
                    <input asp-for="FileReRoute.LoadBalancerOptions.Expiry" class="form-control"/>
                </div>
            </div>
        </div>
    </div>
</div>


@*

public Dictionary<string, string> RouteClaimsRequirement { get; set; }
public FileCacheOptions FileCacheOptions { get; set; }

public FileRateLimitRule RateLimitOptions { get; set; }
public FileHttpHandlerOptions HttpHandlerOptions { get; set; }
*@